﻿using ArtMath.Core.Data;
using ArtMath.Core.Helper;
using System;

namespace ArtMath.PointCollection
{
    [Serializable]
    public class Parabola : ConicBase
    {
        public double FocusDirectrixDistance;
        public Parabola()
        {

        }
        public Parabola(PointD center, double rotate, double p) : base(center, rotate)
        {
            FocusDirectrixDistance = p;
        }
        public override bool Contains(PointD pt)
        {
            PointD f = Center.Offset(RotateAngle, FocusDirectrixDistance / 2);
            return pt.DistanceTo(f).AlmostEqual(pt.DistanceTo(2 * Center - f, -1 / Center.GetSlope(f))) && AfterContains(pt);
        }
    }
}
